﻿using GearOptimizer.Adapters;

namespace GearOptimizer.Factories
{
    public class MongoRepositoryFactory : IRepositoryFactory
    {
        public string ServerName { get; set; }

        public string DatabaseName { get; set; }

        public string Username { get; set; }

        private readonly string password;

        public MongoRepositoryFactory()
        {
        }

        public MongoRepositoryFactory(string serverName, string databaseName, string username = null, string password = null)
        {
            ServerName = serverName;
            DatabaseName = databaseName;
            Username = username;
            this.password = password;
        }

        public IRepository<T> GetRepository<T>() where T : IIdentifiable
        {
            var repository = new MongoRepository<T>(ServerName, DatabaseName, Username, password);
            return repository;
        }
    }
}